#定义和实现感知机的与门
def AND(x1, x2):
    w1 = 0.5
    w2 = 0.5
    theta = 0.7
    temp = x1*w1 + x2*w2
    if temp <= theta:
        print(temp)
        return 0
    elif temp > theta:
        print(temp)
        return 1

print("(0,0) -> ",AND(0,0))
print("(0,0) -> ",AND(1,0))
print("(0,0) -> ",AND(0,1))
print("(0,0) -> ",AND(1,1))
